from celery import Celery

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'lufflyapi.settings.debug')

broker = 'redis://127.0.0.1:6379/1'  # 任务中间件
backend = 'redis://127.0.0.1:6379/2'  # 结果存放

app = Celery(__name__, broker=broker, backend=backend, include=['celery_tasks.task'])


app.conf.timezone = 'Asia/Shanghai'  # 设置时区

app.conf.enable_utc = False  # 禁用utc时间

from datetime import timedelta
from celery.schedules import crontab
app.conf.beat_schedule = {
    "update_task": {
        'task': 'celery_tasks.task.update',  # 指定任务
        'schedule': timedelta(seconds=10),  # 时间间隔
        # 'schedule': crontab(hour=8, day_of_week=1),  # 每周一早上8点执行任务
        # 'args': (4, 6)  # 任务需要的参数
    }
}

